const App = {
    data() {
        return {
            nodeKey: '',
            colunmData: [],
            tableData: [],
            form: {
                PageNumber: 1,
                RowAmount: 100,
                Condition: '',
            },
            Total: 0,
            loading: false,
            name: ''
        }
    },
    mounted() {
        let ls_URL = window.location.href;
        this.nodeKey = getQueryObject(ls_URL, "nodeKey");// 获取 nodeKey 参数
        this.name = getQueryObject(ls_URL, "name");// 获取 nodeKey 参数
        this.getColumn();
    },
    computed: {
        JsonString() {
            return function (str) {
                const isArrayOrObject = (value) => value !== null && typeof value === 'object';
                if (isArrayOrObject(str)) {
                    try {
                        return JSON.stringify(str);
                    } catch (e) { }
                }
                return str;
            }
        }
    },
    methods: {
        handleSizeChange(newSize) {
            this.form.PageNumber = 1;
            this.form.RowAmount = newSize;
            this.getList(this.form);
        },
        handleCurrentChange(newPage) {
            this.form.PageNumber = newPage;
            this.getList(this.form);
        },
        getColumn() {
            this.loading = true;
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryAllColumnByTableName`,
                method: "get",
                data: {
                    Data: this.nodeKey
                },
                success: (Data) => {
                    this.colunmData = Data.filter(i => ![
                        'XLSX_SerialNumber',
                        'Creater_SerialNumber',
                        'Create_Datetime',
                        'Row_Status',
                        'Operation_ID',
                        'Operation_Datetime',
                    ].some(z => z == i.COLUMN_NAME));
                    this.getList(this.form);
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
            });
        },
        getList(data) {
            this.loading = true;
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalPaginateQueryByTableName`,
                method: "post",
                data: {
                    Data: this.nodeKey,
                    ...data
                },
                success: (res) => {
                    this.tableData = res.Rows;
                    this.Total = res.Total 
                },
                complete: (XMLHttpRequest) => {
                    this.loading = false;
                    requestPretreatment(XMLHttpRequest);
                }
            });
        },
        goBack() {
            window.history.back();
        },
    },
};

const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.use(ElementPlus, { locale: zhCn });
app.mount("#app");
